package net.melon.sysres.inst.struts2;

import java.util.Properties;

import net.esj.basic.core.engine.config.Configuration;
import net.esj.basic.plugins.view.FacadeAware;
import net.esj.basic.utils.Validators;
import net.esj.basic.view.BaseAction;
import net.melon.sysres.Constants;

public class SysPropsAction extends BaseAction implements Constants,FacadeAware{
	
	private Properties props;
	private long freeMemoery;
	private long totalMemory;

	private String template;
	private String theme;
	private String namespace; 
	
	public String execute(){
		props = System.getProperties();
		freeMemoery = Runtime.getRuntime().freeMemory();
		totalMemory = Runtime.getRuntime().totalMemory();
		return SUCCESS;
	}

	public Properties getProps() {
		return props;
	}

	public long getFreeMemoery() {
		return freeMemoery;
	}

	public long getTotalMemory() {
		return totalMemory;
	}
	
	protected Configuration configuration;
	
	public void setConfiguration(Configuration configuration) {
		this.configuration = configuration;
	}

	public String getTemplate() {
		return template;
	}

	public void setTemplate(String template) {
		this.template = template;
	}

	public String getTheme() {
		return theme;
	}

	public void setTheme(String theme) {
		this.theme = theme;
	}

	public String getNamespace() {
		return namespace;
	}

	public void setNamespace(String namespace) {
		this.namespace = namespace;
	}

	@Override
	protected String[] getDefaultSources() {
		String str  = configuration.getProperty(DEFAULT_MELON_MESSAGE, null);
		if(Validators.isEmpty(str)){
			return null;
		}
		return new String[]{str};
	}
}
